

window.onload = function () {

    //#region wow.js
    var wow = new WOW({
        boxClass: 'wow', // default
        animateClass: 'animate__animated', // default
        offset: 0, // default
        mobile: true, // default
        live: true // default
    })
    wow.init();
    //#endregion

    //#region 菜单生产三角号
    // 
    // var head_nav = $('.web_nav > ul > li')
    // //    var a_nav=$('.web_nav > ul > li > a')
    // for (let s = 0; s < head_nav.length; s++) {
    //     if (head_nav[s].getElementsByTagName("ul").length > 0) {
    //         var span = document.createElement('b')
    //         // span.innerHTML="▼"
    //         // console.log( head_nav[s].childNodes);
    //         head_nav[s].childNodes[1].append(span);
    //     }
    // }

    // var head_nav_2 = $('.web_nav > ul > li> ul >li')
    // for (let w = 0; w < head_nav_2.length; w++) {
    //     if (head_nav_2[w].getElementsByTagName("ul").length > 0) {
    //         var span = document.createElement('b')
    //         head_nav_2[w].childNodes[1].append(span);
    //     }
    // }
    //#endregion

    //#region 菜单下拉
    $('.webWrap .web_nav >ul >li').each(function(){
        if($(this).hasClass('solution')){
            $('.product_menu').appendTo($(this))
        }
    })

    $('.web_nav ul li >ul').css('display','none')
    // 移入
    $('.web_nav ul >li').mouseenter(function(){
        if($(this).find('.product_menu').length>0){
            $(this).find('.product_menu').stop(true).slideDown(400); 
        }else{
            $(this).find('>ul').addClass('show_list')
            $(this).find('>ul').stop(true).slideDown(400); 
        }
        
     
    })
    // 移出
    $('.web_nav ul li').mouseleave(function(){
        $(this).find('.product_menu').stop(true).slideUp(300)
      $(this).find('>ul').stop(true).slideUp(300); 
    })
   
    // solution菜单切换
    $('.down_menu .left_list ul li').each(function(){
        if($(this).hasClass('active')){
          i = $(this).index();
          $(this).parents('.down_menu').find('.itemWrap').eq(i).removeClass('hide');
        }
        $(this).hover(function(){
          k = $(this).index();
          $(this).addClass('active');
          $(this).siblings().removeClass('active');
         $(this).parents('.down_menu').find('.itemWrap').eq(k).removeClass('hide');
         $(this).parents('.down_menu').find('.itemWrap').eq(k).siblings().addClass('hide');
        })
      })

    //#endregion

   //#region 首页banner

    var mySwiper = new Swiper ('.banner_swiper', {
        // loop: true, // 循环模式选项
        effect: 'fade',
        autoplay: {
            delay: 4000,
            disableOnInteraction: false,
        },
        slidesPerView :1,
        // 如果需要分页器
        pagination: {
        el: '.swiper-pagination',
        clickable:true
        },
    }) 

//#endregion


    //#region 第一屏
    if($('.bannerWrap').length>0){
        let controller = new ScrollMagic.Controller();
        let sense = new ScrollMagic.Scene({
            triggerElement:".bannerWrap",
            triggerHook:"onLeave",
            duration: "120%"
        }) ;
        sense.setPin(".bannerWrap",{pushFollowers:false});
        sense.setTween(".bannerWrap",1,{opacity:0.5});
        controller.addScene(sense);
        // 固定文字
    let whocontent = new ScrollMagic.Scene({
        triggerElement:".whoWrap",
        triggerHook:"onEnter",
    });
    whocontent.setVelocity([".who_content>desc",".who_content>index_title"],{
        top:"0px",
        opacity:"1"
    },{
        duration:800,
        easing:[0.645, 0.045, 0.355, 1]
    });
    controller.addScene(whocontent);

    // 滚动切换内容
        let whoWrap = new ScrollMagic.Scene({
            triggerElement:".whoWrap",
            triggerHook:"onLeave",
            duration: "100%"
        });
        whoWrap.setPin(".whoWrap",{pushFollowers:false});
        let who = new TimelineMax();
        who.add([
            new TweenMax(".video>.left",1,{
                x:-100,
                opacity:0,
                delay:.7,
                autoRound:false
            }),
            new TweenMax(".video>.right",1,{
                x:100,
                opacity:0,
                delay:.7,
                autoRound:false
            }),
            new TweenMax(".num",1,{
                top:"0",
                opacity:1,
                delay:1,
                display:"flex",
                autoRound:false
            }),

        ]);
        whoWrap.setTween(who);
        controller.addScene(whoWrap);
    }
    
  //#endregion


    //#region 第二屏
    
  
//#endregion

    ScrollReveal().reveal('.solution_tab  ', {
        origin: 'top',   // 元素初始位置
        distance: '220px',   // 元素移动的距离
        delay:300,         // 延迟时间
        duration: 1500,     // 动画持续时间
        easing: 'cubic-bezier(0.5, 0, 0, 1)', // 缓动函数
        reset: true,       // 动画重复时是否重置
        opacity: 0,         // 元素初始透明度
    });

    ScrollReveal().reveal('.solution_list  ', {
        origin: 'bottom',   // 元素初始位置
        distance: '100px',   // 元素移动的距离
        delay:300,         // 延迟时间
        duration: 1500,     // 动画持续时间
        easing: 'cubic-bezier(0.5, 0, 0, 1)', // 缓动函数
        reset: true,       // 动画重复时是否重置
    });
    

    
//#region cateSwiper

    var cateSwiper = new Swiper ('.cateSwiper', {
        // loop:true,
        slidesPerView :1,
        spaceBetween : 10,
       
        breakpoints: { 
            1280: {  //当屏幕宽度大于等于1280
                slidesPerView:4,
                spaceBetween: 25
            },
            950: {  //当屏幕宽度大于等于1280
                slidesPerView:3,
                spaceBetween: 25
            },
            450: {  //当屏幕宽度大于等于1280
                slidesPerView:2,
                spaceBetween: 25
            },
           
        },
    })  
    //#endregion


    var solutionSwiper = new Swiper ('.solution_tab', {
        slidesPerView :1,
        spaceBetween : 25,
       
        on: {
            slideChange: function () {
                // 移除所有幻灯片的 active-slide 类
                document.querySelectorAll('.solution_list li').forEach(slide => {
                  slide.classList.remove('current');
                });
                // 给当前激活的幻灯片添加 active-slide 类
                const activeSlide = document.querySelector('.swiper-slide-active');
                if (activeSlide) {
                    i=this.realIndex
                    $('.solution_list li')[i].classList.add('current');
                }
            },
           
        }
    }) 
    
    $('.solutionWrap .solution_list li').eq(0).addClass('current')
    $('.solutionWrap .solution_list li').each(function(){
        $(this).click(function(){
            solutionSwiper.slideTo($(this).index());
        })
    })

    var whySwiper = new Swiper('.whySwiper', {
        slidesPerView:1,
        spaceBetween:10,
        navigation: {
            nextEl: '.why-next',
            prevEl: '.why-prev',
        },
        breakpoints: {
            1280: {
                slidesPerView:4
            },
            950: {
                slidesPerView: 3
            },
           
        }
    })


    var videoSwiper = new Swiper('.videoSwiper', {
        slidesPerView:1,
        spaceBetween:30,
        navigation: {
            nextEl: '.video-next',
            prevEl: '.video-prev',
        },
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
        },
        breakpoints: {
            1280: {
                slidesPerView:3
            },
            950: {
                slidesPerView:2
            },
            480: {
                slidesPerView: 1,
                loop: true
            }
        }
    })


    var jSpeed = 7000 
    var customSwiper = new Swiper ('.customSwiper', {
        loop:true,
        slidesPerView :2,
        spaceBetween : 10,
        speed:jSpeed,
         freedMode:true,
         autoplay:{
             delay:0,
             stopOnLastSlide:false,
             disableOnInteraction:false,
         },
        breakpoints: { 
            1280:{
                slidesPerView:4,
            },
            950: {  //当屏幕宽度大于等于1280
                slidesPerView:4,
                spaceBetween: 25
            },
            450: {  //当屏幕宽度大于等于1280
                slidesPerView:2,
                spaceBetween: 25
            },
           
        },
    }) 

    
/** nextTransForm 移开鼠标后位移到的位置 **/
var nextTransForm = '' 
/** nextSpeed 移开鼠标后位移的时间 **/
var nextSpeed = 0
/** 监听鼠标移到轮播图的子元素上，停止元素 **/
$('.customSwiper .item').on('mouseenter', function () {
 /** 保存下一次移动的位置 **/
 nextTransForm = 'transform:' + $('.customSwiper').find('.swiper-wrapper').eq(0).attr('style').split('transform:')[1].split(';')[0]
 /** 得到下一次移动到子元素左边的位置 **/
 var nextS = -1 * parseInt(nextTransForm.split('translate3d(')[1].split('px')[0])
 /** 得到当前鼠标下子元素上的距离左边的 **/
 var nowS = -1 * parseInt($('.customSwiper').find('.swiper-wrapper').eq(0).css('transform').split('1, ')[2].split(',')[0])
 /** 得到实际上，鼠标移动后，子元素应该移动的时间 **/
 /** 注意这个280，这是我的元素这么宽，你可以写代码获取，这是我懒了 **/
 nextSpeed = jSpeed * ((nextS - nowS) / 280)
 /** transform---设置当前位置；前面的代码是兼容swiper2.0，因为2.0会加点料 **/
 /** transition-duration:0ms;让元素不移动 **/
 $('.customSwiper').find('.swiper-wrapper').eq(0).attr('style', `${$('.customSwiper').find('.swiper-wrapper').eq(0).attr('style').split('transform: ')[0]}transform: ${$('.customSwiper').find('.swiper-wrapper').eq(0).css('transform')};transition-duration:0ms;`)
});
/** 监听鼠标移开轮播图的子元素，轮播图继续滚动 **/
$('.customSwiper .item').on('mouseleave', function () {
  /** 讲刚刚的内容直接放上去，然后就会发现又动起来了，且无缝，类似上面的暂停代码 **/
 $('.customSwiper').find('.swiper-wrapper').eq(0).attr('style', `${$('.customSwiper').find('.swiper-wrapper').eq(0).attr('style').split('transform: ')[0]}${nextTransForm};transition-duration:${nextSpeed}ms;`)
//  customSwiper.autoplayStart()
}); 


    var CertificateSwiper = new Swiper ('.CertificateSwiper', {
        // loop:true,
        slidesPerView :2,
        spaceBetween : 10,
        navigation: {
            nextEl: '.certificate-next',
            prevEl: '.certificate-prev',
        },
       
        breakpoints: { 
            1280:{
                slidesPerView:4,
                spaceBetween: 25
            },
            950: {  //当屏幕宽度大于等于1280
                slidesPerView:3,
                spaceBetween: 25
            },
            450: {  //当屏幕宽度大于等于1280
                slidesPerView:2,
                spaceBetween: 25
            },
        },
    }) 

//#region case
    var caseSwiper = new Swiper ('.caseSwiper', {
        // loop:true,
        slidesPerView :1,
        navigation: {
            nextEl: '.case-next',
            prevEl: '.case-prev',
        },
        pagination: {
            el: '.swiper-pagination',
            type : 'progressbar',
          },
        breakpoints: { 
            950: {  //当屏幕宽度大于等于1280
                slidesPerView :1.6,
            },
        },
    }) 
    ScrollReveal().reveal('.index_case .Wrap', {
        origin: 'right',   // 元素初始位置
        distance: '200px',   // 元素移动的距离
        delay:300,         // 延迟时间
        duration: 1000,     // 动画持续时间
        easing: 'ease-in-out', // 缓动函数
        reset: true,       // 动画重复时是否重置
    });

//#endregion

//#region newSwiper
    var newSwiper = new Swiper ('.newSwiper', {
        // loop:true,
        slidesPerView :1,
        spaceBetween: 25,
        navigation: {
            nextEl: '.news-next',
            prevEl: '.news-prev',
        },
        breakpoints: { 
            1280: {  //当屏幕宽度大于等于1280
                slidesPerView :3,
            },
            950: {  //当屏幕宽度大于等于1280
                slidesPerView :2,
            },
        },
    }) 

//#endregion

//#region 动效展示
    if( $(window).width()>1280){
    
        ScrollReveal().reveal('.newSwiper .swiper-slide:first-of-type  ', {
            origin: 'bottom',  
            distance: '200px',   
            delay:300,      
            duration: 1200,     
            easing: 'ease-in-out',
            reset: true,      
        });
        ScrollReveal().reveal('.newSwiper .swiper-slide:nth-child(2)', {
            origin: 'bottom',  
            distance: '200px',  
            delay:500,         
            duration: 1200,    
            easing: 'ease-in-out',
            reset: true,     
        });
        ScrollReveal().reveal('.newSwiper .swiper-slide:nth-child(3)', {
            origin: 'bottom',  
            distance: '200px',  
            delay:700,       
            duration: 1200,  
            easing: 'ease-in-out',
            reset: true,      
        });
        ScrollReveal().reveal('.CertificateSwiper .swiper-slide', {
            origin: 'bottom',   // 元素初始位置
            distance: '100px',   // 元素移动的距离
            delay:300,         // 延迟时间
            duration: 1500,     // 动画持续时间
            easing: 'cubic-bezier(0.5, 0, 0, 1)', // 缓动函数
            reset: true,       // 动画重复时是否重置
            mobile: true 
        });
    
        ScrollReveal().reveal('.cateSwiper .swiper-slide:first-of-type  ', {
            origin: 'bottom',  
            distance: '200px',   
            delay:300,      
            duration: 1200,     
            easing: 'ease-in-out',
            reset: true,      
        });
        ScrollReveal().reveal('.cateSwiper .swiper-slide:nth-child(2)', {
            origin: 'bottom',  
            distance: '200px',  
            delay:500,         
            duration: 1200,    
            easing: 'ease-in-out',
            reset: true,     
        });
        ScrollReveal().reveal('.cateSwiper .swiper-slide:nth-child(3)', {
            origin: 'bottom',  
            distance: '200px',  
            delay:700,       
            duration: 1200,  
            easing: 'ease-in-out',
            reset: true,      
        });
        ScrollReveal().reveal('.cateSwiper .swiper-slide:nth-child(4)', {
            origin: 'bottom', 
            distance: '200px',
            delay:900,      
            duration: 1200,    
            easing: 'ease-in-out', 
            reset: true,       
        });
    
    
    }
       
    //#endregion


ScrollReveal().reveal('.index_inquiry .Wrap', {
    scale: 0.8,
    delay:300,         // 延迟时间
    duration: 1800,     // 动画持续时间
    easing: 'cubic-bezier(0.5, 0, 0, 1)', // 缓动函数
    reset: true,       // 动画重复时是否重置
});


    // solution菜单切换
    $('.keyWrap .list li').each(function(){
        if($(this).hasClass('active')){
          i = $(this).index();
          $(this).parents('.keyWrap').find('.item').eq(i).removeClass('hide');
        }
        $(this).click(function(){
          k = $(this).index();
          $(this).addClass('active');
          $(this).siblings().removeClass('active');
         $(this).parents('.keyWrap').find('.item').eq(k).removeClass('hide');
         $(this).parents('.keyWrap').find('.item').eq(k).siblings().addClass('hide');
        })
      })
    
    var solutionlistSwiper = new Swiper ('.solutionlistSwiper', {
        // loop:true,
        slidesPerView :1,
        spaceBetween: 25,
        navigation: {
            nextEl: '.list-next',
            prevEl: '.list-prev',
        },
        breakpoints: { 
            1280: {  //当屏幕宽度大于等于1280
                slidesPerView :3,
            },
            950: {  //当屏幕宽度大于等于1280
                slidesPerView :2,
            },
        },
    }) 

    var solutionlistSwiper = new Swiper ('.workShop', {
        loop:true,
        slidesPerView :2,
        spaceBetween: 25,
        centeredSlides: true,
        pagination: {
            el: '.swiper-pagination',
        },
    }) 
    var solutionlistSwiper = new Swiper ('.caseWrap', {
        loop:true,
        slidesPerView :2.5,
        spaceBetween: 25,
        centeredSlides: true,
        pagination: {
            el: '.swiper-pagination',
        },
    })



    //#region 产品详情页产品图
    var swiper = new Swiper('.image-additional', {
        slidesPerView: 3,
        spaceBetween: 0,
        watchOverflow: true,
        pagination: {
            el: '.product-view .swiper-pagination',
            clickable: true,
        },
        navigation: {
            nextEl: '.product-view .swiper-button-next',
            prevEl: '.product-view .swiper-button-prev',
        },
        breakpoints: {
            1366: {
                slidesPerView: 3
            },
            950: {
                slidesPerView: 3
            },
            480: {
                slidesPerView: 1,
                loop: true
            }
        }
    })
    //#endregion

    //#region 产品详情页推荐产品
    var relatedSwiper = new Swiper('.goods-may-like .swiper-slider', {
        slidesPerView: 2,
        spaceBetween: 0,
        speed: 400,
        watchOverflow: true,
        navigation: {
            nextEl: '.goods-may-like .swiper-button-next',
            prevEl: '.goods-may-like .swiper-button-prev',
        },
        pagination: {
            el: '.goods-may-like .swiper-pagination',
            clickable: true,
        },
        breakpoints: {
            1680: {
                slidesPerView: 3
            },
            1024: {
                slidesPerView: 3
            },
            768: {
                slidesPerView: 2
            },
            480: {
                slidesPerView: 2,
                slidesPerGroup: 2,
                loop: true
            }
        }
    });
    //#endregion


       //#region 数字跳动
       var window_height = document.documentElement.clientHeight
       var adoutNum = $('.aboutNum')
       var num = document.querySelectorAll('.numadd')
       var slop = false
       window.onscroll = function () {
           if (slop) return
           // 数字跳动
           var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
           if ($('.aboutNum').length > 0) {
               if (scrollTop >= adoutNum.offset().top - window_height && scrollTop <= adoutNum.offset().top) {
                   slop = true
                   for (let i = 0; i < num.length; i++) {
                       const numadd = num[i];
                       numadd.classList.add('timer');
                       // 动态数字触发
                       $('.timer').each(count);
                       function count(options) {
                           var $this = $(this);
                           options = $.extend({}, options || {}, $this.data('countToOptions') || {});
                           $this.countTo(options);
                       }
                   }
               }
           }

       }
   //#endregion

   
    if ($('.index_faq').length > 0) {
        var liList = $('.faq>ul>li')
        var answerList =$('.faq .answer')
        answerList[0].style.display = 'block';
        liList[0].classList.add("open");
        // 循环所有问题   
        for (var i = 0; i < liList.length; i++) {
            liList[i].onclick = function () {
            if ($(this).find('.answer').css('display') == 'none') {
                $(this).addClass('open').siblings().removeClass('open')
                $(this).siblings().find('.answer').slideUp(150)
                $(this).find('.answer').slideDown(150)
            } else {
                $(this).find('.answer').slideUp(150)
                $(this).removeClass('open')
            }
            }
        }
    }


}




//#region  弹出表单
function hideMsgPop() { $('.inquiry-pop-bd').fadeOut('fast') }
if ($('body .inquiry-form-wrap').length > 0) {
    var webTop = $('body .inquiry-form-wrap').offset().top - 80
    $('.product-btn-wrap .email,.company_subscribe .button,.side_content .side_list .email, .btn,.product_btn_inquiry,.inquiry_btn').click(function () {
        $("html, body").animate({ scrollTop: webTop }, 1000);
        $(".ad_prompt").show().delay(3000).hide(300);
    })
} else {
    $('.product-btn-wrap .email,.company_subscribe .button,.side_content .side_list .email,.btn,.product_btn_inquiry,.inquiry_btn').click(function () {
        $('.inquiry-pop-bd').fadeIn('fast')
    })
}
$('.inquiry-pop,.product-btn-wrap .email,.company_subscribe .button,.side_content .side_list .email,.btn,.product_btn_inquiry,.inquiry_btn').click(function (e) { e.stopPropagation(); })
$(document).click(function () { hideMsgPop() })
//#endregion


//#region 全局搜索search
if ($('.web-search')) {
    document.documentElement.className = 'js';; (function (window) {
        if (document.querySelector('.web-search')) {
            'use strict'; var mainContainer = document.querySelector('body'), searchContainer = document.querySelector('.web-search'), openCtrl = document.getElementById('btn-search'), closeCtrl = document.getElementById('btn-search-close'), inputSearch = searchContainer.querySelector('.search-ipt'); function init() { initEvents() } function initEvents() {
                openCtrl.addEventListener('click', function () { if (!searchContainer.classList.contains("search--open")) { openSearch(); } else { closeSearch(); } });
                closeCtrl.addEventListener('click', closeSearch); document.addEventListener('keyup', function (ev) { if (ev.keyCode == 27) { closeSearch() } })
            } function openSearch() { mainContainer.classList.add('main-wrap--move'); searchContainer.classList.add('search--open'); setTimeout(function () { inputSearch.focus() }, 600) } function closeSearch() { mainContainer.classList.remove('main-wrap--move'); searchContainer.classList.remove('search--open'); inputSearch.blur(); inputSearch.value = '' } init()
        }
    })(window);
}

//#endregion

//#region 多语言

$(document).ready(function () {
    $('.change-language .change-language-cont').append("<div class='change-empty'>Untranslated</div>")
    $('.prisna-wp-translate-seo').append("<div class='lang-more'>More Language</div>")
    if ($('body .prisna-wp-translate-seo').length > 0 && $('.change-language .prisna-wp-translate-seo').length < 1) {
        $('.prisna-wp-translate-seo').appendTo('.change-language .change-language-cont')
        if ($('.change-language .change-language-cont .prisna-wp-translate-seo li').length > 0) {
            $('.change-language .change-language-cont .change-empty').hide()
            $('.change-language .change-language-cont .prisna-wp-translate-seo li').each(function (index) {
                if (index > 35) {
                    $(this).addClass('lang-item lang-item-hide')
                    $('.change-language-cont').find('.lang-more').fadeIn()
                } else {
                    $('.change-language-cont').find('.lang-more').fadeOut()
                }
            })
            if ($('.change-language-cont .lang-more').length > 0) {
                $('.change-language-cont .lang-more').click(function () {
                    if ($(this).parents('.change-language-cont').find('.prisna-wp-translate-seo li.lang-item').hasClass('lang-item-hide')) {
                        $(this).parents('.change-language-cont').find('.prisna-wp-translate-seo li.lang-item').removeClass('lang-item-hide')
                        $(this).addClass('more-active').text('×')
                    } else {
                        $(this).parents('.change-language-cont').find('.prisna-wp-translate-seo li.lang-item').addClass('lang-item-hide')
                        $(this).removeClass('more-active').text('More Language')
                    }
                })
            }
        } else {
            $('.change-language .change-language-cont .change-empty').fadeIn()
        }
    }
})
//#endregion

//#region  web导航

var $nav = $('.page_head'),
    navTop = $('.web_nav').offset().top,
    headH = $nav.outerHeight(),
    winTop_1 = 0,
    winWidth = $(window).width(),
    winHeight = $(window).height(),
    spr = $('body').height() - $nav.height(),
    holder = jQuery('<div class="head_holder">');
$(window).on('scroll', function () {
    var winTop_2 = $(window).scrollTop();
    holder.css('height', headH);

    if (winTop_2 > headH && winWidth > 950) {
        holder.show().appendTo($nav);
        $nav.addClass('fixed-nav');
        $nav.parents('body').addClass('fixed-body');
        setTimeout(function () { $nav.addClass('fixed-nav-active') });
    } else {
        holder.hide();
        $nav.removeClass('fixed-nav fixed-nav-active');
        $nav.parents('body').removeClass('fixed-body');
    }

    if (winTop_2 > winTop_1 && winWidth > 950) {
        $nav.removeClass('fixed-nav-appear');
    } else if (winTop_2 < winTop_1) {
        $nav.addClass('fixed-nav-appear');
    }
    winTop_1 = $(window).scrollTop();
})
//#endregion

//#region 手机端导航

function mSizeChange() {
    if (window.innerWidth)
        winWidth = window.innerWidth;
    else if ((document.body) && (document.body.clientWidth))
        winWidth = document.body.clientWidth;
    if (window.innerHeight)
        winHeight = window.innerHeight;
    else if ((document.body) && (document.body.clientHeight))
        winHeight = document.body.clientHeight;
    if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
        winHeight = document.documentElement.clientHeight;
        winWidth = document.documentElement.clientWidth;
    }
    if (winWidth <= 950) {
        if ($('.phone-head-items').length < 1) {
            var phoneService = '<div class="phone-head-items"><div class="phone_logo"></div><div class="itemWrap"><div class="phone-head-item phone-head-nav"><div class="title"><i class="iconfont icon-caidan"></i></div><div class="main-content-wrap side-content-wrap"><div class="content-wrap"></div></div></div><div class="phone-head-item phone-head-language"><div class="title"><i class="iconfont icon-duoyuyanguanli"></i></div><div class="main-content-wrap side-content-wrap"><div class="content-wrap"></div></div></div><div class="phone-head-item phone-head-search"><div class="title"><i class="iconfont icon-sousuo"></i></div><div class="main-content-wrap middle-content-wrap"><div class="content-wrap"></div></div></div></div>'
            $('body').append(phoneService)
            if ($('body .aside').length > 0) {
                $('.phone-head-items .itemWrap').append('<div class="phone-head-item phone-head-aside"><div class="title"></div><div class="main-content-wrap side-content-wrap"><div class="content-wrap"></div></div></div>')
            }
            $('.phone-head-item').each(function () {
                $(this).find('.title').click(function () {
                    if ($(this).parents('.phone-head-item').find('.main-content-wrap').length > 0) {
                        var pItem = $(this).parents('.phone-head-item')
                        if (!pItem.find('.main-content-wrap').hasClass('show-content-wrap')) {
                            pItem.find('.main-content-wrap').addClass('show-content-wrap')
                            pItem.find('.side-content-wrap').stop().animate({ 'left': '0' }, 300)
                            pItem.find('.middle-content-wrap').addClass('middle-show-content-wrap')
                            pItem.find('.side-content-wrap').append("<b class='phone-ico-close'></b>")
                            pItem.siblings('.phone-head-item').find('.main-content-wrap').removeClass('show-content-wrap')
                            pItem.siblings('.phone-head-item').find('.side-content-wrap').stop().animate({ 'left': '-70%' }, 300)
                            pItem.siblings('.phone-head-item').find('.middle-content-wrap').removeClass('middle-show-content-wrap')
                            pItem.siblings('.phone-head-item').find('.side-content-wrap .phone-ico-close').remove()
                            if ($('.phone-head-items').find('.phone-body-mask').length < 1) {
                                $('.phone-head-items').append('<div class="phone-body-mask"></div>')
                            }
                        }
                        else {
                            pItem.find('.main-content-wrap').removeClass('show-content-wrap')
                            pItem.find('.side-content-wrap').stop().animate({ 'left': '-70%' }, 300)
                            pItem.find('.middle-content-wrap').removeClass('middle-show-content-wrap')
                            pItem.find('.side-content-wrap .phone-ico-close').remove()
                        }
                        $('.phone-body-mask').click(function () {
                            $('.phone-body-mask').remove()
                            $('.phone-head-item .main-content-wrap').removeClass('show-content-wrap')
                            $('.phone-head-item .side-content-wrap').animate({ 'left': '-70%' }, 300)
                            $('.phone-head-item .middle-content-wrap').removeClass('middle-show-content-wrap')
                            $('.phone-head-item .side-content-wrap .phone-ico-close').remove()
                        })
                        $('.phone-ico-close').click(function () {
                            $('.phone-body-mask').remove()
                            $('.phone-head-item .main-content-wrap').removeClass('show-content-wrap')
                            $('.phone-head-item .side-content-wrap').stop().animate({ 'left': '-70%' }, 300)
                            $('.phone-head-item .middle-content-wrap').removeClass('middle-show-content-wrap')
                            $('.phone-head-item .side-content-wrap .phone-ico-close').remove()
                        })
                    }
                })
            })
            $('.change-currency ').clone().appendTo('.phone-head-item.phone-head-currency .main-content-wrap .content-wrap')
            $('.page_head .Wrapper .logo a').clone().appendTo('.phone-head-items .phone_logo')
            $('.change-language .change-language-cont').clone().appendTo('.phone-head-item.phone-head-language .main-content-wrap .content-wrap')
            $('.web_nav>ul').clone().appendTo('.phone-head-item.phone-head-nav .main-content-wrap .content-wrap')
            $('.head-search:last').clone().appendTo('.phone-head-item.phone-head-search .main-content-wrap .content-wrap')
            $('.head_sns').clone().appendTo('.phone-head-item.phone-head-social .main-content-wrap .content-wrap')
            $('.aside .aside-wrap').clone().appendTo('.phone-head-item.phone-head-aside .main-content-wrap .content-wrap')
        }
    }
    //phone end
    else {
        $(document).ready(function () {
            $('.phone-body-mask,.phone-head-items,.phone-head-items,.phone-nav-items,.phone-cart-items,.phone-tab-items').remove()
        });
    }
}
$(function () { mSizeChange(); })
$(window).resize(function () { mSizeChange() });

//#endregion

//#region  滚动到头部

var mHeadTop = $('.page_head').offset().top
var $backToTopTxt = "TOP",
    $backToTopEle = $('<span class="gotop"></span>').appendTo($("body"))
        .html('<em>' + $backToTopTxt + '</em>').attr("title", $backToTopTxt).click(function () {
            $("html, body").animate({ scrollTop: 0 }, 600);
        }),
    $backToTopFun = function () {
        var st = $(document).scrollTop(),
            winh = $(window).height();
        (st > mHeadTop) ? $backToTopEle.addClass('active') : $backToTopEle.removeClass('active');
        if (!window.XMLHttpRequest) {
            $backToTopEle.css("top", st + winh - 210);
        }
    };
$(window).bind("scroll", $backToTopFun);
$(function () { $backToTopFun(); });

//#endregion

//#region  侧边栏
$('.side-widget .side-cate li').each(function () {
    if ($(this).find('ul').length > 0) {
        $(this).append("<span class='icon-cate icon-cate-down'></span>")
        $(this).children('.icon-cate').click(function (e) {
            if ($(this).parent('li').children('ul').is(':hidden')) {
                $(this).parent('li').children('ul').slideDown(100);
                $(this).removeClass('icon-cate-down').addClass('icon-cate-up');
            } else {
                $(this).parent('li').children('ul').slideUp(100);
                $(this).removeClass('icon-cate-up').addClass('icon-cate-down');
            }
            e.stopPropagation();
        })
    }
})

if ($('.side-widget .side-cate .nav-current').parents('ul').length > 0 && $('.side-widget .side-cate .nav-current').find('ul').length > 0) {
    $('.side-widget .side-cate .nav-current').parents('ul').show()
    $('.side-widget .side-cate .nav-current').parents('li').addClass("show_li")
    $('.side-widget .side-cate .nav-current').parents('li.show_li').children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up')
    $('.side-widget .side-cate .nav-current').children('ul').show()
    $('.side-widget .side-cate .nav-current ').children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up');
}
else if ($('.side-widget .side-cate .nav-current').parents('ul').length > 0 && $('.side-widget .side-cate .nav-current').find('ul').length < 1) {
    $('.side-widget .side-cate .nav-current').parents('ul').show()
    $('.side-widget .side-cate .nav-current').parents('li').addClass("show_li")
    $('.side-widget .side-cate .nav-current').parents('li.show_li').children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up')
}
else if ($('.side-widget .side-cate .nav-current').parents('ul').length < 1 && $('.side-widget .side-cate .nav-current').find('ul').length > 0) {
    $('.side-widget .side-cate .nav-current').children('ul').show()
    $('.side-widget .side-cate .nav-current').children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up');
}

//#endregion